fix: env field in config, PostHog no-op in dev/test#415
Merged
Conversation
…ents Adds `env: Literal["prod", "dev", "test"]` to `AuthsomeConfig` (read from `AUTHSOME_ENV`) so the runtime environment is a first-class config concern shared across client and server. Gates `analytics_enabled` on `env == "prod"` in `ServerConfig` so PostHog is never initialised in dev or test — preventing the background consumer thread from blocking pytest process exit and causing CI jobs to hang until the 6-hour GitHub Actions timeout. Test suite now sets `AUTHSOME_ENV=test` at module level and in the `_disable_analytics` autouse fixture. The CI workflow also sets it as defence-in-depth and adds `timeout-minutes: 10` so runaway jobs fail fast. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
env: Literal["prod", "dev", "test"]toAuthsomeConfig(read fromAUTHSOME_ENV, defaults to"prod") — process-wide, not server-onlyServerConfig.analytics_enablednow short-circuits whenenv != "prod", making PostHog a strict no-op in dev and testtests/conftest.pysetsAUTHSOME_ENV=testat module level and in the_disable_analyticsautouse fixture.github/workflows/python-test.ymladdsAUTHSOME_ENV: test(defence-in-depth) andtimeout-minutes: 10so runaway jobs fail in 10 min instead of hitting the 6-hour GitHub limitRoot cause (CI hang in #409)
The PostHog SDK's
shutdown()joins a consumer thread that makes real HTTP connections. Even without an API key,enable_exception_autocapture=Trueinstalls process-wide hooks that can leave non-daemon threads alive after the test suite finishes.pytest-timeout'ssignalmethod (SIGALRM) cannot interrupt C-level thread waits, so pytest hung until GitHub cancelled the job at 6 hours.Test plan
uv run pytest— 340 passed in ~4suv run ruff check— cleanuv run ty check— clean🤖 Generated with Claude Code